#include <windows.h>
#include <stdio.h>
#include "../Pipe/pipe_server.h"


#ifdef UNICODE 
#define SNPRINTF _snwprintf
#else
#define SNPRINTF _snprintf
#endif /*UNICODE*/


DWORD WINAPI demo_etAnswerToRequest_Thread
(
IN  void* pinbuff, 
IN  size_t insize,
OUT void *poutbuff, 
IN  size_t outsize, 
IN  unsigned int* lpretsize
)
{
	BYTE btmp[256] = { 0 };
	size_t ret = 0 ;
	
	ret = SNPRINTF(&btmp[0],sizeof(btmp),TEXT("THIS is server response,clientsize is %u,pinbuff %s"),insize,(char*)pinbuff);
	
	ret = ret * 2 ;

	memcpy(poutbuff,&btmp[0],min(ret,outsize));
	
	*lpretsize =ret;
	
	return 0;
}



int main(int argc, char *argv[]) 
{
	while(1)
	{
		Pipe_main(10,demo_etAnswerToRequest_Thread);
		Sleep(1000);
	}


	return 0;
}